﻿using System;
using System.Collections.Generic;
using System.Drawing.Imaging;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MovieBuddy.Helpers
{
    public static class MovieConstants
    {
        public static string[] MovieExtensions
        {

            get
            {
                return new[]
                {
                    "iso",
                    "mpeg",
                    "mpg",
                    "mp4",
                    "wmv",
                    "avi",
                    "mov",
                    "ogg"
                };
            }
        }

        public static bool IsMovieExtension(string extension)
        {
            if (extension.StartsWith(".")) extension = extension.Substring(1);
            extension = extension.ToLower();
            return MovieExtensions.Contains(extension);
        }

        private readonly static string[] imageExtensions = ImageCodecInfo.GetImageEncoders().SelectMany(enc =>
                        enc.FilenameExtension.Split(';').Select(e => e.Substring(2).ToLower())
                        ).ToArray();

        public static string[] ImageExtensions
        {
            get
            {
                var ret = new string[imageExtensions.Length];
                imageExtensions.CopyTo(ret, 0);
                return ret;
            }
        }

        public static bool IsImageExtension(string extension)
        {
            if (extension.StartsWith(".")) extension = extension.Substring(1);
            extension = extension.ToLower();
            return imageExtensions.Contains(extension);
        }
    }
}
